package com.yoomiito.app.present.my.fragment;

import com.yoomiito.app.Constant;
import com.yoomiito.app.model.my.MyHistoryIncomeInfo;
import com.yoomiito.app.net.YmApi;
import com.yoomiito.app.ui.fragment.my.MyHistoryIncomeFragment;
import com.yoomiito.app.utils.NetworkUtils;
import com.yoomiito.app.utils.YMToast;

import cn.droidlover.xdroidmvp.mvp.XPresent;
import cn.droidlover.xdroidmvp.net.ApiException;
import cn.droidlover.xdroidmvp.net.ApiSubscriber;
import cn.droidlover.xdroidmvp.net.XApi;

public class MyHistoryIncomeFmPresenter extends XPresent<MyHistoryIncomeFragment> {

    public void getHistoryOrderData(int page){
        YmApi.getYmService()
                .getHistoryIncome(page,Constant.PAGE_SIZE)
                .compose(getV().bindToLifecycle())
                .compose(XApi.<MyHistoryIncomeInfo>getApiTransformerData())
                .compose(XApi.<MyHistoryIncomeInfo>getScheduler())
                .subscribe(new ApiSubscriber<MyHistoryIncomeInfo>() {
                    @Override
                    public void onSuccess(MyHistoryIncomeInfo data) {
                        getV().setHistoryOrderData(data);
                    }

                    @Override
                    public void onFail(ApiException error) {
                        YMToast.showText("error");
                    }
                });
    }
}
